package main

import (
	"360/video-srv/basic/config"
	"360/video-srv/basic/inits"
	__ "360/video-srv/basic/proto"
	"360/video-srv/services"
	"flag"
	"log"
	"net"

	"google.golang.org/grpc"
)

// server is used to implement helloworld.GreeterServer.

func main() {
	flag.Parse()
	lis, err := net.Listen("tcp", "127.0.0.1:50051")
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	config.InitConfig()
	inits.InitMysql()
	inits.InitRedis()
	inits.InitEs()
	__.RegisterVideoServer(s, &services.Server{})
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
